home *** CD-ROM | disk | FTP | other *** search
/ The PC-SIG Library 10 / The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso / PC_SIGCD / 05 / 6 / DISK0564.ZIP / SOURCE.ARC / B.ARC / DOSCALL.AS < prev    next >
Text File  |  1986-03-29  |  2KB  |  63 lines

  1. ;       general-purpose bdos gate
  2. ;       written for Aztec C86 v. 3.20e
  3. ;       by Jon Dart, Mar. 1986
  4.  
  5. MODEL equ 0         ;small code, small data
  6.  
  7. include  lmacros.h
  8.  
  9. ;  unsigned int doscall(function,inptr,outptr)
  10. ;  int function; struct regs *inptr,*outptr;
  11. ;  /* sets ah=function #, calls dos, returns regs */
  12. ;  /* also returns fn value <> 0 if carry flag set on return from dos */
  13. ;   /* regptr is a pointer to a struct:
  14. ;   struct regs {
  15. ;       unsigned int ax,bx,cx,dx,si,di;
  16. ;   }; */
  17. codeseg segment
  18. procdef doscall,<<arg1,word>,<arg2,word>,<arg3,word>>
  19.         pushds
  20.         push si
  21.         push di
  22.         ldptr si,arg2     ;get 2nd argument = pointer to structure.
  23.         mov  ax,[si+10]   ;get value of di
  24.         mov  di,ax        ;load it
  25.         mov  bx,[si+2]    ;then bx
  26.         mov  cx,[si+4]    ;then cx
  27.         mov  dx,[si+6]    ;then dx
  28.         mov  ax,arg1      ;get 1st argument = function #
  29.         mov  ah,al        ;function # in ah
  30.         mov  al,[si]      ;load al from reg structure
  31.         push ax           ;save ax
  32.         mov  ax,[si+8]    ;get value to load into si
  33.         mov  si,ax        ;load it
  34.         pop  ax           ;restore ax
  35.         int  21h          ;call dos
  36.         pushf
  37.         push si
  38.         ldptr si,arg3     ;get arg3
  39.         mov [si],ax       ;save ax
  40.         mov [si+2],bx     ;and bx
  41.         mov [si+4],cx     ;and cx
  42.         mov [si+6],dx     ;and dx
  43.         mov ax,di         ;get di
  44.         mov [si+10],ax    ;save it
  45.         pop ax            ;get si
  46.         mov [si+8],ax     ;save it
  47.         popf
  48.         pop  di
  49.         pop  si
  50.         popds
  51.         jb   errorret     ;branch on carry
  52.         xor  ax,ax        ;normal return
  53.         pret              ;return to caller
  54. errorret:
  55.         mov  ax,1         ;error return
  56.         pret
  57.         pend doscall
  58.         finish
  59. codeseg ends
  60.         end
  61.  
  62.  
  63.